﻿//=====================================================================================================
// LocalizationLibrary
// The Localization Library is a collection of reusable software component that provide 
// support for localization. This library enable you to localize WPF, Silverlight and WP7 applications.
// (http://localizationlibrary.codeplex.com)
//=====================================================================================================
// Author: Nicola Gallo (Website: www.nicola.gallo.name, Email: nicolagmt@hotmail.it) 
//=====================================================================================================

namespace ReflectionStudio.LocalizationLibrary
{
    //.NET References
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;  
    /// <summary>
    /// Defines a <see cref="LocalizationProvider"/> that use the web service defined in the solution HelloWorld.Services.
    /// </summary>
    public class VMLocalizationProvider : LocalizationProvider
    {
        //Constructors
        public ResourceManager RM = new ResourceManager();
        /// <summary>
        /// Creates a new instance of <see cref="LocalizationProvider"/> class.
        /// </summary>
        /// <param name="token">Token to localize.</param>
        /// <param name="onLocalization">Callback to call when the <see cref="LocalizationProvider"/> has completed the localization.</param>
        /// <exception cref="ArgumentNullcExeption">
        /// Thrown whether <paramref name="token"/> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentNullcExeption">
        /// Thrown whether <paramref name="onLocalization"/> parameter is null.
        /// </exception>
        public VMLocalizationProvider(DynamicResourceToken token,
            LocalizationCompletionCallback onLocalization)
            : base(token, onLocalization) { }
       
        //Methods

        /// <summary>
        /// Localize the input <paramref name="dynamicResourceToken"/> for the input <paramref name="language"/>.
        /// </summary>
        public override void Localize()
        {
            this.Token.Value = RM.GetResourceValue(this.Token.ResourceID, this.Token.Language.Code);
            this.PublishLocalization();
        }
    }
}
